﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Check_montlyPV
/// </summary>
/// 

namespace Bestlife.ERP.BusinessRules
{

    public class Check_montlyPV:System.Web.UI.Page
    {
        int st = 0;
        Boolean chk = false;
        Boolean lshipchk = false;
        SqlDataReader rdrssql;

        public Check_montlyPV()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        public Boolean check_monthlyPV(String id, String user_status)
        {
            
            try
            {



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String ssqlchk = "SElECT ppv FROM Bonus WHERE User_id='" + id + "'";

                rdrssql = Bestlife.ERP.DataAccess.clsCon.ReadTable(ssqlchk);

                while (rdrssql.Read())
                {
                    // parentID = rdRStatus["user_Status"].ToString();

                    Double getpv = Double.Parse(rdrssql["ppv"].ToString());

                    if ((getpv >=25.00) && (user_status.Equals("2") || user_status.Equals("3") || user_status.Equals("4") || user_status.Equals("5") || user_status.Equals("6")))
                    {
                        chk = true;
                    }

                    else if (getpv >= 50 && user_status.Equals("7"))
                    {
                        chk = true;
                    }

                    else if (getpv >= 75 && user_status.Equals("8"))
                    {
                        chk = true;
                    }

                    else if (getpv >= 100 && user_status.Equals("9"))
                    {
                        chk = true;
                    }

                    else if (getpv >= 200 && user_status.Equals("10"))
                    {
                        chk = true;
                    }


                }
            }

            catch
            {
                Server.Transfer("404.aspx");

            }

            finally
            {
                rdrssql.Close();
            }

            return chk;
        }

        //check mothly lship_st >


        public Boolean check_monthlyLshipPV(String id, String user_status)
        {

            try
            {



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String ssqlchk = "SElECT Lship_Status FROM Bonus WHERE User_id='" + id + "'";

                rdrssql = Bestlife.ERP.DataAccess.clsCon.ReadTable(ssqlchk);

                while (rdrssql.Read())
                {
                    // parentID = rdRStatus["user_Status"].ToString();

                    Double getMonth_pv = Double.Parse(rdrssql["Lship_Status"].ToString());

                    if (getMonth_pv >= 600 && user_status.Equals("7"))
                    {
                        lshipchk = true;
                    }

                    else if (getMonth_pv >= 1000 && user_status.Equals("8"))
                    {
                        lshipchk = true;
                    }

                    else if (getMonth_pv >= 1500 && user_status.Equals("9"))
                    {
                        lshipchk = true;
                    }

                    else if (getMonth_pv >= 2000 && user_status.Equals("10"))
                    {
                        lshipchk = true;
                    }


                }
            }

            catch
            {
                Server.Transfer("404.aspx");

            }

            finally
            {
                rdrssql.Close();
            }

            return lshipchk;
        }






        //use in cartcheck
        public int first_status(String id, double productpv)
        {

            try
            {


                        if (productpv < 25.00)
                    {

                        st = 1;
                    }
                        else if (productpv >= 300.00 && productpv <= 1200.00)
                    {
                        st = 5;
                    }

                        else if (productpv >= 200.00 && productpv <= 300.00)
                    {
                        st = 4;
                    }

                        else if (productpv >= 100.00 && productpv <= 200.00)
                    {
                        st = 3;
                    }

                        else if (productpv>= 50.00 && productpv<= 100.00)
                    {
                        st = 2;
                    }

           }


            catch
            {
                Server.Transfer("404.aspx");

            }

            finally
            {
                //rdrssql.Close();
            }

            return st;
        }


    }
}